package com.open.launcher.helper;



import com.open.launcher.bean.RequestDto;
import com.open.launcher.bean.details.PlayDetailsBean;
import com.open.launcher.callback.IRequestLisenter;
import com.open.launcher.callback.RequestCallback;
import com.open.launcher.utils.OkGoUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wendal on 2017/10/19.
 */

public class HotItemHelper {
    private RequestCallback callBack;
    private List<PlayDetailsBean> playDetailsBeanList;

    public HotItemHelper() {
        playDetailsBeanList = new ArrayList<>();
    }

    public void setCallback(RequestCallback callback) {
        this.callBack = callback;
    }
    public void loadData(String url) {

        OkGoUtil<PlayDetailsBean> okGoUtil = new OkGoUtil<PlayDetailsBean>(PlayDetailsBean.class, OkGoUtil.TYPE_ARRAY, new IRequestLisenter() {
            @Override
            public void onSuccessData(RequestDto dto) {
                playDetailsBeanList = (List<PlayDetailsBean>) dto.getList();
                if (callBack != null) {
                    callBack.onLoadComplete("", 0, playDetailsBeanList.size(), playDetailsBeanList);
                }
            }

            @Override
            public void onErrer(int code, String errMsg) {
            }
        });
        okGoUtil.requestGet(url);
    }
}
